<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>8-marginTop塌陷问题</title>
    <style>
        .box{
            width: 500px;
            height: 500px;
            background: red;
            margin: 30px auto;
            /* 解决办法1 */
            /* overflow: hidden; */
            /* 解决办法2 */
            border: 1px solid transparent;
        }
        /* 让图片距离顶部100px */
        .box img{
            margin-top: 100px;
        }
        .box span{
            width: 100px;
            height: 100px;
            display: block;
            background: blue;
            margin-top: 100px;
        }
    </style>
</head>
<body>
    <!-- 
        marginTop塌陷出现的场景:
            父元素中行内元素设定宽高之后，添加margin-top没有生效
            解决办法：
                1)在父元素上添加 overflow:hidden
                2)在父元素上添加透明的边线
     -->
    <div class="box">
        <!-- <img src="images/200.png" alt=""> -->
        <span></span>
    </div>
</body>
</html>